<table class="table2" id="tbl_price" border="0" cellpadding="3" cellspacing="0">
    <thead>
        <tr>
            <td class="room_cell" width="25%"><h3>Chi tiết phòng</h3></td>
            <td class="rates_cell" width="10%"><h3> Ngày</h3></td>          <td class="rates_cell" width="15%">
                <h3> Giá căn bản</h3></td>          <td class="rates_cell" width="15%"><h3> VAT &amp; Phí*</h3></td>
            <td class="rates_cell" width="20%"><h3> Thanh toán</h3></td>          
        </tr>
    </thead>
    <tbody>

        <!--Phòng 1-->
        <tr class="blue_background" id="roomQuote-0" >
            <td class="room_cell" rowspan="<?php echo $records['sodem'] + 1; ?>">
                <span id="roomNumber-0"><b> Phòng 1</b></span>
                <br/>
                <span id="numAdults-0"> Số lượng người lớn: <?php echo $songuoilon1; ?></span>
                <br/>
                <span id="numChildren-0"><?php if ($sotreem1 > 0) echo 'Số lượng trẻ em: ' . $sotreem1; ?></span>
            </td>
        </tr>
        <?php
        $ts = mktime(0, 0, 0, $thangbatdau, $ngaybatdau, $nambatdau);
        $songay = date('t', $ts);
        for ($i = 0; $i < $records['sodem']; $i++) {
            $d = $ngaybatdau + $i;
            if ($d < $songay + 1) {
                $ts = mktime(0, 0, 0, $thangbatdau, $d, $nambatdau);
            } else {
                $d = $d - $songay;
                $t = $thangbatdau + 1;
                $n = $nambatdau;
                if ($t > 12) {
                    $t = 1;
                    $n = $n + 1;
                }
                $ts = mktime(0, 0, 0, $t, $d, $n);
            }
            ?>
            <tr class="blue_background" id="nightDetails-0-0" >
                <td class="rates_cell">
                    <span id="bookingNightDate-0-0" style="display:none;"><?php echo date("d/m/Y", $ts) ?></span>
                    <span><?php echo date("d/m/Y", $ts) ?></span>
                </td>
                <td class="rates_cell"><span id="bookingNightPrice-0-0"><?php echo number_format($records['phong'][$i]->GiaSauKhuyenMai * 1000, 0, ',', '.'); ?> VND</span></td>
                <td class="rates_cell"><span id="extrasRetailIncTax-0-0"><?php
        if ($songuoilon1 <= $loaiphong[0]->SoNguoiLonMacDinh)
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
        else
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon1 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.');
            ?> VND</span></td>
                <td class="rates_cell"><span id="bookingNightTotalPrice-0-0"><?php
                    if ($songuoilon1 <= $loaiphong[0]->SoNguoiLonMacDinh)
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
                    else
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon1 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.')
                ?> VND</span></td>
                
            </tr>
        <?php } ?>

        <!--end Phòng 1-->
        <?php if ($sophong > 1) { ?>
            <!--Phòng 2-->
            <tr class="blue_background" id="roomQuote-0" >
                <td class="room_cell" rowspan="<?php echo $records['sodem'] + 1; ?>">
                    <span id="roomNumber-0"><b> Phòng 2</b></span>
                    <br/>
                    <span id="numAdults-0"> Số lượng người lớn: <?php echo $songuoilon2; ?></span>
                    <br/>
                    <span id="numChildren-0"><?php if ($sotreem2 > 0) echo 'Số lượng trẻ em: ' . $sotreem2; ?></span>
                </td>
            </tr>
            <?php
            $ts = mktime(0, 0, 0, $thangbatdau, $ngaybatdau, $nambatdau);
            $songay = date('t', $ts);
            for ($i = 0; $i < $records['sodem']; $i++) {
                $d = $ngaybatdau + $i;
                if ($d < $songay + 1) {
                    $ts = mktime(0, 0, 0, $thangbatdau, $d, $nambatdau);
                } else {
                    $d = $d - $songay;
                    $t = $thangbatdau + 1;
                    $n = $nambatdau;
                    if ($t > 12) {
                        $t = 1;
                        $n = $n + 1;
                    }
                    $ts = mktime(0, 0, 0, $t, $d, $n);
                }
                ?>
                <tr class="blue_background" id="nightDetails-0-0">
                    <td class="rates_cell">
                        <span id="bookingNightDate-0-0" style="display:none;"><?php echo date("d/m/Y", $ts) ?></span>
                        <span><?php echo date("d/m/Y", $ts) ?></span>
                    </td>
                    <td class="rates_cell"><span id="bookingNightPrice-0-0"><?php echo number_format($records['phong'][$i]->GiaSauKhuyenMai * 1000, 0, ',', '.'); ?> VND</span></td>
                    <td class="rates_cell"><span id="extrasRetailIncTax-0-0"><?php
        if ($songuoilon2 <= $loaiphong[0]->SoNguoiLonMacDinh)
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
        else
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon2 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.');
                ?> VND</span></td>
                    <td class="rates_cell"><span id="bookingNightTotalPrice-0-0"><?php
                    if ($songuoilon2 <= $loaiphong[0]->SoNguoiLonMacDinh)
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
                    else
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon2 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.')
                    ?> VND</span></td>
                    
                </tr>
            <?php } ?>

            <!--end Phòng 2-->
        <?php } ?>

        <?php if ($sophong > 2) { ?>
            <!--Phòng 3-->
            <tr class="blue_background" id="roomQuote-0" >
                <td class="room_cell" rowspan="<?php echo $records['sodem'] + 1; ?>">
                    <span id="roomNumber-0"><b> Phòng 3</b></span>
                    <br/>
                    <span id="numAdults-0"> Số lượng người lớn: <?php echo $songuoilon3; ?></span>
                    <br/>
                    <span id="numChildren-0"><?php if ($sotreem3 > 0) echo 'Số lượng trẻ em: ' . $sotreem3; ?></span>
                </td>
            </tr>
            <?php
            $ts = mktime(0, 0, 0, $thangbatdau, $ngaybatdau, $nambatdau);
            $songay = date('t', $ts);
            for ($i = 0; $i < $records['sodem']; $i++) {
                $d = $ngaybatdau + $i;
                if ($d < $songay + 1) {
                    $ts = mktime(0, 0, 0, $thangbatdau, $d, $nambatdau);
                } else {
                    $d = $d - $songay;
                    $t = $thangbatdau + 1;
                    $n = $nambatdau;
                    if ($t > 12) {
                        $t = 1;
                        $n = $n + 1;
                    }
                    $ts = mktime(0, 0, 0, $t, $d, $n);
                }
                ?>
                <tr class="blue_background" id="nightDetails-0-0">
                    <td class="rates_cell">
                        <span id="bookingNightDate-0-0" style="display:none;"><?php echo date("d/m/Y", $ts) ?></span>
                        <span><?php echo date("d/m/Y", $ts) ?></span>
                    </td>
                    <td class="rates_cell"><span id="bookingNightPrice-0-0"><?php echo number_format($records['phong'][$i]->GiaSauKhuyenMai * 1000, 0, ',', '.'); ?> VND</span></td>
                    <td class="rates_cell"><span id="extrasRetailIncTax-0-0"><?php
        if ($songuoilon3 <= $loaiphong[0]->SoNguoiLonMacDinh)
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
        else
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon3 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.');
                ?> VND</span></td>
                    <td class="rates_cell"><span id="bookingNightTotalPrice-0-0"><?php
                    if ($songuoilon3 <= $loaiphong[0]->SoNguoiLonMacDinh)
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
                    else
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon3 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.')
                    ?> VND</span></td>
                    
                </tr>
            <?php } ?>

            <!--end Phòng 3-->
        <?php } ?>

        <?php if ($sophong > 3) { ?>
            <!--Phòng 4-->
            <tr class="blue_background" id="roomQuote-0" >
                <td class="room_cell" rowspan="<?php echo $records['sodem'] + 1; ?>">
                    <span id="roomNumber-0"><b> Phòng 4</b></span>
                    <br/>
                    <span id="numAdults-0"> Số lượng người lớn: <?php echo $songuoilon4; ?></span>
                    <br/>
                    <span id="numChildren-0"><?php if ($sotreem4 > 0) echo 'Số lượng trẻ em: ' . $sotreem4; ?></span>
                </td>
            </tr>
            <?php
            $ts = mktime(0, 0, 0, $thangbatdau, $ngaybatdau, $nambatdau);
            $songay = date('t', $ts);
            for ($i = 0; $i < $records['sodem']; $i++) {
                $d = $ngaybatdau + $i;
                if ($d < $songay + 1) {
                    $ts = mktime(0, 0, 0, $thangbatdau, $d, $nambatdau);
                } else {
                    $d = $d - $songay;
                    $t = $thangbatdau + 1;
                    $n = $nambatdau;
                    if ($t > 12) {
                        $t = 1;
                        $n = $n + 1;
                    }
                    $ts = mktime(0, 0, 0, $t, $d, $n);
                }
                ?>
                <tr class="blue_background" id="nightDetails-0-0" >
                    <td class="rates_cell">
                        <span id="bookingNightDate-0-0" style="display:none;"><?php echo date("d/m/Y", $ts) ?></span>
                        <span><?php echo date("d/m/Y", $ts) ?></span>
                    </td>
                    <td class="rates_cell"><span id="bookingNightPrice-0-0"><?php echo number_format($records['phong'][$i]->GiaSauKhuyenMai * 1000, 0, ',', '.'); ?> VND</span></td>
                    <td class="rates_cell"><span id="extrasRetailIncTax-0-0"><?php
        if ($songuoilon4 <= $loaiphong[0]->SoNguoiLonMacDinh)
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
        else
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon4 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.');
                ?> VND</span></td>
                    <td class="rates_cell"><span id="bookingNightTotalPrice-0-0"><?php
                    if ($songuoilon4 <= $loaiphong[0]->SoNguoiLonMacDinh)
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
                    else
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon4 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.')
                    ?> VND</span></td>
                    
                </tr>
            <?php } ?>

            <!--end Phòng 4-->
        <?php } ?>

        <?php if ($sophong > 4) { ?>
            <!--Phòng 5-->
            <tr class="blue_background" id="roomQuote-0" >
                <td class="room_cell" rowspan="<?php echo $records['sodem'] + 1; ?>">
                    <span id="roomNumber-0"><b> Phòng 5</b></span>
                    <br/>
                    <span id="numAdults-0"> Số lượng người lớn: <?php echo $songuoilon5; ?></span>
                    <br/>
                    <span id="numChildren-0"><?php if ($sotreem5 > 0) echo 'Số lượng trẻ em: ' . $sotreem5; ?></span>
                </td>
            </tr>
            <?php
            $ts = mktime(0, 0, 0, $thangbatdau, $ngaybatdau, $nambatdau);
            $songay = date('t', $ts);
            for ($i = 0; $i < $records['sodem']; $i++) {
                $d = $ngaybatdau + $i;
                if ($d < $songay + 1) {
                    $ts = mktime(0, 0, 0, $thangbatdau, $d, $nambatdau);
                } else {
                    $d = $d - $songay;
                    $t = $thangbatdau + 1;
                    $n = $nambatdau;
                    if ($t > 12) {
                        $t = 1;
                        $n = $n + 1;
                    }
                    $ts = mktime(0, 0, 0, $t, $d, $n);
                }
                ?>
                <tr class="blue_background" id="nightDetails-0-0">
                    <td class="rates_cell">
                        <span id="bookingNightDate-0-0" style="display:none;"><?php echo date("d/m/Y", $ts) ?></span>
                        <span><?php echo date("d/m/Y", $ts) ?></span>
                    </td>
                    <td class="rates_cell"><span id="bookingNightPrice-0-0"><?php echo number_format($records['phong'][$i]->GiaSauKhuyenMai * 1000, 0, ',', '.'); ?> VND</span></td>
                    <td class="rates_cell"><span id="extrasRetailIncTax-0-0"><?php
        if ($songuoilon5 <= $loaiphong[0]->SoNguoiLonMacDinh)
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
        else
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon5 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.');
                ?> VND</span></td>
                    <td class="rates_cell"><span id="bookingNightTotalPrice-0-0"><?php
                    if ($songuoilon5 <= $loaiphong[0]->SoNguoiLonMacDinh)
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
                    else
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon5 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.')
                    ?> VND</span></td>
                    
                </tr>
            <?php } ?>

            <!--end Phòng 5-->

        <?php } ?>

        <?php if ($sophong > 5) { ?>
            <!--Phòng 6-->
            <tr class="blue_background" id="roomQuote-0" >
                <td class="room_cell" rowspan="<?php echo $records['sodem'] + 1; ?>">
                    <span id="roomNumber-0"><b> Phòng 6</b></span>
                    <br/>
                    <span id="numAdults-0"> Số lượng người lớn: <?php echo $songuoilon6; ?></span>
                    <br/>
                    <span id="numChildren-0"><?php if ($sotreem6 > 0) echo 'Số lượng trẻ em: ' . $sotreem6; ?></span>
                </td>
            </tr>
            <?php
            $ts = mktime(0, 0, 0, $thangbatdau, $ngaybatdau, $nambatdau);
            $songay = date('t', $ts);
            for ($i = 0; $i < $records['sodem']; $i++) {
                $d = $ngaybatdau + $i;
                if ($d < $songay + 1) {
                    $ts = mktime(0, 0, 0, $thangbatdau, $d, $nambatdau);
                } else {
                    $d = $d - $songay;
                    $t = $thangbatdau + 1;
                    $n = $nambatdau;
                    if ($t > 12) {
                        $t = 1;
                        $n = $n + 1;
                    }
                    $ts = mktime(0, 0, 0, $t, $d, $n);
                }
                ?>
                <tr class="blue_background" id="nightDetails-0-0">
                    <td class="rates_cell">
                        <span id="bookingNightDate-0-0" style="display:none;"><?php echo date("d/m/Y", $ts) ?></span>
                        <span><?php echo date("d/m/Y", $ts) ?></span>
                    </td>
                    <td class="rates_cell"><span id="bookingNightPrice-0-0"><?php echo number_format($records['phong'][$i]->GiaSauKhuyenMai * 1000, 0, ',', '.'); ?> VND</span></td>
                    <td class="rates_cell"><span id="extrasRetailIncTax-0-0"><?php
        if ($songuoilon6 <= $loaiphong[0]->SoNguoiLonMacDinh)
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
        else
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon6 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.');
                ?> VND</span></td>
                    <td class="rates_cell"><span id="bookingNightTotalPrice-0-0"><?php
                    if ($songuoilon6 <= $loaiphong[0]->SoNguoiLonMacDinh)
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
                    else
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon6 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.')
                    ?> VND</span></td>
                    
                </tr>
            <?php } ?>

            <!--end Phòng 6-->
        <?php } ?>

        <?php if ($sophong > 6) { ?>
            <!--Phòng 7-->
            <tr class="blue_background" id="roomQuote-0" >
                <td class="room_cell" rowspan="<?php echo $records['sodem'] + 1; ?>">
                    <span id="roomNumber-0"><b> Phòng 7</b></span>
                    <br/>
                    <span id="numAdults-0"> Số lượng người lớn: <?php echo $songuoilon7; ?></span>
                    <br/>
                    <span id="numChildren-0"><?php if ($sotreem7 > 0) echo 'Số lượng trẻ em: ' . $sotreem7; ?></span>
                </td>
            </tr>
            <?php
            $ts = mktime(0, 0, 0, $thangbatdau, $ngaybatdau, $nambatdau);
            $songay = date('t', $ts);
            for ($i = 0; $i < $records['sodem']; $i++) {
                $d = $ngaybatdau + $i;
                if ($d < $songay + 1) {
                    $ts = mktime(0, 0, 0, $thangbatdau, $d, $nambatdau);
                } else {
                    $d = $d - $songay;
                    $t = $thangbatdau + 1;
                    $n = $nambatdau;
                    if ($t > 12) {
                        $t = 1;
                        $n = $n + 1;
                    }
                    $ts = mktime(0, 0, 0, $t, $d, $n);
                }
                ?>
                <tr class="blue_background" id="nightDetails-0-0" >
                    <td class="rates_cell">
                        <span id="bookingNightDate-0-0" style="display:none;"><?php echo date("d/m/Y", $ts) ?></span>
                        <span><?php echo date("d/m/Y", $ts) ?></span>
                    </td>
                    <td class="rates_cell"><span id="bookingNightPrice-0-0"><?php echo number_format($records['phong'][$i]->GiaSauKhuyenMai * 1000, 0, ',', '.'); ?> VND</span></td>
                    <td class="rates_cell"><span id="extrasRetailIncTax-0-0"><?php
        if ($songuoilon7 <= $loaiphong[0]->SoNguoiLonMacDinh)
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
        else
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon7 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.');
                ?> VND</span></td>
                    <td class="rates_cell"><span id="bookingNightTotalPrice-0-0"><?php
                    if ($songuoilon7 <= $loaiphong[0]->SoNguoiLonMacDinh)
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
                    else
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon7 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.')
                    ?> VND</span></td>
                    
                </tr>
            <?php } ?>

            <!--end Phòng 7-->
        <?php } ?>

        <?php if ($sophong > 7) { ?>
            <!--Phòng 8-->
            <tr class="blue_background" id="roomQuote-0" >
                <td class="room_cell" rowspan="<?php echo $records['sodem'] + 1; ?>">
                    <span id="roomNumber-0"><b> Phòng 8</b></span>
                    <br/>
                    <span id="numAdults-0"> Số lượng người lớn: <?php echo $songuoilon8; ?></span>
                    <br/>
                    <span id="numChildren-0"><?php if ($sotreem8 > 0) echo 'Số lượng trẻ em: ' . $sotreem8; ?></span>
                </td>
            </tr>
            <?php
            $ts = mktime(0, 0, 0, $thangbatdau, $ngaybatdau, $nambatdau);
            $songay = date('t', $ts);
            for ($i = 0; $i < $records['sodem']; $i++) {
                $d = $ngaybatdau + $i;
                if ($d < $songay + 1) {
                    $ts = mktime(0, 0, 0, $thangbatdau, $d, $nambatdau);
                } else {
                    $d = $d - $songay;
                    $t = $thangbatdau + 1;
                    $n = $nambatdau;
                    if ($t > 12) {
                        $t = 1;
                        $n = $n + 1;
                    }
                    $ts = mktime(0, 0, 0, $t, $d, $n);
                }
                ?>
                <tr class="blue_background" id="nightDetails-0-0">
                    <td class="rates_cell">
                        <span id="bookingNightDate-0-0" style="display:none;"><?php echo date("d/m/Y", $ts) ?></span>
                        <span><?php echo date("d/m/Y", $ts) ?></span>
                    </td>
                    <td class="rates_cell"><span id="bookingNightPrice-0-0"><?php echo number_format($records['phong'][$i]->GiaSauKhuyenMai * 1000, 0, ',', '.'); ?> VND</span></td>
                    <td class="rates_cell"><span id="extrasRetailIncTax-0-0"><?php
        if ($songuoilon8 <= $loaiphong[0]->SoNguoiLonMacDinh)
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
        else
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon8 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.');
                ?> VND</span></td>
                    <td class="rates_cell"><span id="bookingNightTotalPrice-0-0"><?php
                    if ($songuoilon8 <= $loaiphong[0]->SoNguoiLonMacDinh)
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
                    else
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon8 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.')
                    ?> VND</span></td>
                    
                </tr>
            <?php } ?>

            <!--end Phòng 8-->
        <?php } ?>

        <?php if ($sophong > 8) { ?>
            <!--Phòng 9-->
            <tr class="blue_background" id="roomQuote-0" >
                <td class="room_cell" rowspan="<?php echo $records['sodem'] + 1; ?>">
                    <span id="roomNumber-0"><b> Phòng 9</b></span>
                    <br/>
                    <span id="numAdults-0"> Số lượng người lớn: <?php echo $songuoilon9; ?></span>
                    <br/>
                    <span id="numChildren-0"><?php if ($sotreem9 > 0) echo 'Số lượng trẻ em: ' . $sotreem9; ?></span>
                </td>
            </tr>
            <?php
            $ts = mktime(0, 0, 0, $thangbatdau, $ngaybatdau, $nambatdau);
            $songay = date('t', $ts);
            for ($i = 0; $i < $records['sodem']; $i++) {
                $d = $ngaybatdau + $i;
                if ($d < $songay + 1) {
                    $ts = mktime(0, 0, 0, $thangbatdau, $d, $nambatdau);
                } else {
                    $d = $d - $songay;
                    $t = $thangbatdau + 1;
                    $n = $nambatdau;
                    if ($t > 12) {
                        $t = 1;
                        $n = $n + 1;
                    }
                    $ts = mktime(0, 0, 0, $t, $d, $n);
                }
                ?>
                <tr class="blue_background" id="nightDetails-0-0">
                    <td class="rates_cell">
                        <span id="bookingNightDate-0-0" style="display:none;"><?php echo date("d/m/Y", $ts) ?></span>
                        <span><?php echo date("d/m/Y", $ts) ?></span>
                    </td>
                    <td class="rates_cell"><span id="bookingNightPrice-0-0"><?php echo number_format($records['phong'][$i]->GiaSauKhuyenMai * 1000, 0, ',', '.'); ?> VND</span></td>
                    <td class="rates_cell"><span id="extrasRetailIncTax-0-0"><?php
        if ($songuoilon9 <= $loaiphong[0]->SoNguoiLonMacDinh)
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
        else
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon9 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.');
                ?> VND</span></td>
                    <td class="rates_cell"><span id="bookingNightTotalPrice-0-0"><?php
                    if ($songuoilon9 <= $loaiphong[0]->SoNguoiLonMacDinh)
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
                    else
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon9 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.')
                    ?> VND</span></td>
                    
                </tr>
            <?php } ?>

            <!--end Phòng 9-->
        <?php } ?>

        <?php if ($sophong > 9) { ?>
            <!--Phòng 10-->
            <tr class="blue_background" id="roomQuote-0" >
                <td class="room_cell" rowspan="<?php echo $records['sodem'] + 1; ?>">
                    <span id="roomNumber-0"><b> Phòng 10</b></span>
                    <br/>
                    <span id="numAdults-0"> Số lượng người lớn: <?php echo $songuoilon10; ?></span>
                    <br/>
                    <span id="numChildren-0"><?php if ($sotreem10 > 0) echo 'Số lượng trẻ em: ' . $sotreem10; ?></span>
                </td>
            </tr>
            <?php
            $ts = mktime(0, 0, 0, $thangbatdau, $ngaybatdau, $nambatdau);
            $songay = date('t', $ts);
            for ($i = 0; $i < $records['sodem']; $i++) {
                $d = $ngaybatdau + $i;
                if ($d < $songay + 1) {
                    $ts = mktime(0, 0, 0, $thangbatdau, $d, $nambatdau);
                } else {
                    $d = $d - $songay;
                    $t = $thangbatdau + 1;
                    $n = $nambatdau;
                    if ($t > 12) {
                        $t = 1;
                        $n = $n + 1;
                    }
                    $ts = mktime(0, 0, 0, $t, $d, $n);
                }
                ?>
                <tr class="blue_background" id="nightDetails-0-0" >
                    <td class="rates_cell">
                        <span id="bookingNightDate-0-0" style="display:none;"><?php echo date("d/m/Y", $ts) ?></span>
                        <span><?php echo date("d/m/Y", $ts) ?></span>
                    </td>
                    <td class="rates_cell"><span id="bookingNightPrice-0-0"><?php echo number_format($records['phong'][$i]->GiaSauKhuyenMai * 1000, 0, ',', '.'); ?> VND</span></td>
                    <td class="rates_cell"><span id="extrasRetailIncTax-0-0"><?php
        if ($songuoilon10 <= $loaiphong[0]->SoNguoiLonMacDinh)
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
        else
            echo number_format(($khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon10 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.');
                ?> VND</span></td>
                    <td class="rates_cell"><span id="bookingNightTotalPrice-0-0"><?php
                    if ($songuoilon10 <= $loaiphong[0]->SoNguoiLonMacDinh)
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu) * 1000, 0, ',', '.');
                    else
                        echo number_format(($records['phong'][$i]->GiaSauKhuyenMai + $khachsan[0]->VAT * $records['phong'][$i]->GiaSauKhuyenMai / 100 + $khachsan[0]->PhiDichVu + ($songuoilon10 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh) * 1000, 0, ',', '.')
                    ?> VND</span></td>
                    
                </tr>
            <?php } ?>

            <!--end Phòng 10-->
        <?php } ?>

    </tbody>
</table>
<div class="clear"></div>
<span>(*) Bao gồm thuế VAT (<?php echo $khachsan[0]->VAT; ?> %), phí phục vụ khách sạn và phụ thu tiền phòng (thêm người, giường) nếu có</span>
<br/>    <br/>
<div  id="nhapthei12">
    <table border="0" width="940">
        <tbody>
            <tr>
                <?php if ($sothe == 0) { ?>
                    <td id="td1" style="width: 20%;line-height: 17px;"><h3>Nhập số thẻ i12
                            <span style="font-size:12px;color: #6C6C6C;font-weight: normal;">(nếu có)</span>
                        </h3><a target="_blank" href="<?php echo base_url('index.php/loiichthei12') ?>">(Lợi ích thẻ i12)
                        </a>
                    </td>
                    <td  id="td2" style="width: 210px;padding-left: 1px;">
                        <input style="width:200px;margin: 0;padding: 1px 0;border: 2px solid #E3E3E3;" id="dealnumber" name="dealNo" value="" type="text"/>
                    </td>
                    <td  id="td3" style="width: 100px;text-align:left;">
                        <a class="input_dealNo" href="javascript:getDealNo();" id="thei12">Nhập
                        </a>
                    </td>
                <?php } else { ?>
                    <td id="td4"  style="width: 20%;line-height: 17px;"><h3>Số thẻ i12: 
                        </h3><a target="_blank" href="<?php echo base_url('index.php/loiichthei12') ?>">(Lợi ích thẻ i12)
                        </a>
                    </td>
                    <td  id="td5" style="width: 210px;padding-left: 1px;">
                        <h3><?php echo $sothe; ?></h3>
                    </td>
                    <td  id="td6" style="width: 100px;text-align:left;">
                        <a class="input_dealNo" href="javascript:getDealNo();" id="thei12doi">Đổi
                        </a>
                    </td>            
                <?php } ?>
                <td style="background-color: #F8FBFC;border: 1px solid #F2F2FE;">
                    <table>
                        <input type="hidden" value="<?php echo $sothe; ?>" id="sothe" name="sothe"/>
                        <input type="hidden" value="<?php echo $phantramgiam; ?>" id="phantramgiam" name="phantramgiam"/>
                        <input type="hidden" value="<?php echo $diem; ?>" id="diem" name="diem"/>
                        <tbody>
                            <tr>
                                <td style="width: 235px;">
                                    <h3> Tổng số tiền</h3></td>
                                <td align="center"><h3 id="subTotal">
                                        <?php
                                        $tonggia = $records['tonggia'] * $sophong;
                                        $tonggia = $tonggia + $tonggia * $khachsan[0]->VAT / 100;
                                        $tonggia = $tonggia + $khachsan[0]->PhiDichVu * $records['sodem'] * $sophong;
                                        if ($sophong > 0)
                                            if ($songuoilon1 > $loaiphong[0]->SoNguoiLonMacDinh)
                                                $tonggia = $tonggia + ($songuoilon1 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh * $records['sodem'];
                                        if ($sophong > 1)
                                            if ($songuoilon2 > $loaiphong[0]->SoNguoiLonMacDinh)
                                                $tonggia = $tonggia + ($songuoilon2 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh * $records['sodem'];
                                        if ($sophong > 2)
                                            if ($songuoilon3 > $loaiphong[0]->SoNguoiLonMacDinh)
                                                $tonggia = $tonggia + ($songuoilon3 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh * $records['sodem'];
                                        if ($sophong > 3)
                                            if ($songuoilon4 > $loaiphong[0]->SoNguoiLonMacDinh)
                                                $tonggia = $tonggia + ($songuoilon4 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh * $records['sodem'];
                                        if ($sophong > 4)
                                            if ($songuoilon5 > $loaiphong[0]->SoNguoiLonMacDinh)
                                                $tonggia = $tonggia + ($songuoilon5 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh * $records['sodem'];
                                        if ($sophong > 5)
                                            if ($songuoilon6 > $loaiphong[0]->SoNguoiLonMacDinh)
                                                $tonggia = $tonggia + ($songuoilon6 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh * $records['sodem'];
                                        if ($sophong > 6)
                                            if ($songuoilon7 > $loaiphong[0]->SoNguoiLonMacDinh)
                                                $tonggia = $tonggia + ($songuoilon7 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh * $records['sodem'];
                                        if ($sophong > 7)
                                            if ($songuoilon8 > $loaiphong[0]->SoNguoiLonMacDinh)
                                                $tonggia = $tonggia + ($songuoilon8 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh * $records['sodem'];
                                        if ($sophong > 8)
                                            if ($songuoilon9 > $loaiphong[0]->SoNguoiLonMacDinh)
                                                $tonggia = $tonggia + ($songuoilon9 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh * $records['sodem'];
                                        if ($sophong > 9)
                                            if ($songuoilon10 > $loaiphong[0]->SoNguoiLonMacDinh)
                                                $tonggia = $tonggia + ($songuoilon10 - $loaiphong[0]->SoNguoiLonMacDinh) * $loaiphong[0]->SoTienThemNguoiHienHanh * $records['sodem'];
                                        
										$giam = (floor($phantramgiam * $tonggia / 100)+1) * 1000;
                                        echo number_format($tonggia * 1000, 0, ',', '.');
										
										
                                        ?> VND</h3>
                                       
                                    <h3><input type="hidden" name="total_" id="total_" value="<?php echo ($tonggia * 1000 - $giam); ?>"/>
									<input type="hidden" name="totaltong" id="totaltong" value="<?php echo $tonggia * 1000; ?>"/>
                                        <input type="hidden" name="totalgiam" id="totalgiam" value="<?php echo $giam; ?>"/>
                                        <input type="hidden" name="totalconlai" id="totalconlai" value="<?php echo ($tonggia * 1000 - $giam); ?>"/>
                                    </h3>
			<?php
			$amount = number_format($tonggia * 1000 - $giam, 0, ',', '');
			$from_currency = "VND";
			$to_currency = "USD";
			$submit_url = "http://www.google.com/ig/calculator?hl=en&q=$amount$from_currency=?$to_currency";
			$chr = curl_init();
			
			curl_setopt ($chr, CURLOPT_URL, $submit_url);
			curl_setopt ($chr, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($chr,  CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
			curl_setopt ($chr, CURLOPT_CONNECTTIMEOUT, 0);
			 $data = curl_exec($chr);
			curl_close($chr);
			$data = explode('"', $data);
			$rate=$data[3];
			$rate = substr($rate, 0, -13);
			
			$numberpart=explode('.',$rate);  
			$numberpart[1]=substr_replace($numberpart[1],'.',2,0);
			if($numberpart[0]>=0)
			{$numberpart[1]=ceil($numberpart[1]);}
			else
			{$numberpart[1]=floor($numberpart[1]);}
		
			$ceil_number= array($numberpart[0],$numberpart[1]);
			$totalPrice = implode('.',$ceil_number);
			?>
                                </td>            </tr>
                                 
                            <tr id="giam" style="<?php if ($sothe == 0) echo 'display:none'; ?>"><td style="width: 235px;">
                                    <h2> Đã giảm</h2></td>
                                <td align="center"><h2 id="subTotal1"><?php echo number_format($giam, 0, ',', '.'); ?> VND</h2>


                                    <h3></h3>
                                </td>
                            </tr>
                            <tr id="conlai" style="<?php if ($sothe == 0) echo 'display:none'; ?>"><td style="width: 235px;">
                                    <h3> Số tiền còn lại</h3></td>
                                <td align="center"><h3 id="subTotal2"><?php echo number_format($tonggia * 1000 - $giam, 0, ',', '.'); ?> VND</h3>


                                    <h3></h3>
                                </td>
                            </tr>
							<tr>
                                   <td>&nbsp;</td>
                                   <td><h3>
                                   <input type="hidden" name="total2_" id="total2_" value="<?php echo ' (' . $totalPrice . ' USD)'; ?>"/>
                                   <input type="hidden" value="<?php echo $totalPrice; ?>" id="totalPrice" name = 'totalPrice'/>
                                   &nbsp;&nbsp;(<?php echo $totalPrice; ?> USD)</h3></td>
                                 </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
        </tbody>
    </table>
</div>

<script type="text/javascript">    
    $('#thei12').click(function() {
                                                                                                                                                                    
        var form_data = {
            sothe:$('#dealnumber').val(),
            tongtien:$('#totaltong').val()
        };
        $.ajax({
            url: "<?php echo site_url('datphong/loadthekhuyenmai'); ?>",
            type:"POST",
            data: form_data,
            dataType: 'html',
            success: function(msg){
                $('#nhapthei12').html(msg);
                $('#creditCardPayment').text($('#total_').val());
                $('#creditCardPayment2').text($('#total2_').val());
                                                                                                                                                                            
            }
        });
    });
    $('#thei12doi').click(function() {
        var form_data = {
            sothe:0,
            tongtien:$('#totaltong').val()
        };
        $.ajax({
            url: "<?php echo site_url('datphong/loadthekhuyenmai'); ?>",
            type:"POST",
            data: form_data,
            dataType: 'html',
            success: function(msg){
                $('#nhapthei12').html(msg);
                $('#creditCardPayment').text($('#total_').val());
                $('#creditCardPayment2').text($('#total2_').val());
                                                                                                                                                                            
            }
        });
    });
    $('#total_').priceFormat({
        prefix: '',
        centsSeparator: '',
        suffix: ' VND',
        thousandsSeparator: '.',
        limit: 15,
        centsLimit: 0
    });
	
</script>